new Vue({
    el: '#app',
    data() {
        return {
            // 设置每个分片的大小（字节）
            CHUNK_SIZE: 5 * 1024 * 1024 + "", // 1MB
            retryNum: 0,
            myindex: -1,
            imgSuffix: ["jpg", "jpeg", "png", "bmp", "heic"],
            //尺寸规格列表
            sizeList: [{id: '1', title: '一寸',mmSize:'25x36mm',pxSize: '295*413px', pxWidth: 295, pxHeight: 413},
                {id: '2', title: '二寸',mmSize:'35x49mm',pxSize: '415x579px', pxWidth: 415, pxHeight: 579},
                {id: '3', title: '三寸',mmSize:'58x84mm',pxSize: '650x992px', pxWidth: 650, pxHeight: 992}
            ],
            //尺寸规格列表
            bgColorList: [
                {id: '1', colorStyle: '#FFFFFF', colorStyle2: 'rgb(255,255,255)', bgColor: '#FFFFFF', bgColor2: ''},
                {id: '2', colorStyle: '#518fda', colorStyle2: 'rgb(81,143,218)', bgColor: '#518fda', bgColor2: ''},
                {id: '3', colorStyle: '#ea3325', colorStyle2: 'rgb(234,51,37)', bgColor: '#ea3325', bgColor2: ''},
                {id: '4', colorStyle: 'linear-gradient(#3492C4, #FFFFFF)', colorStyle2: 'rgb(52,146,196)', bgColor: '#3492C4', bgColor2: '#FFFFFF'},
                {id: '5', colorStyle: '#74b6f3', colorStyle2: 'rgb(116,182,243)', bgColor: '#74b6f3', bgColor2: ''},
                {id: '6', colorStyle: '#eebfb5', colorStyle2: 'rgb(238,191,181)', bgColor: '#eebfb5', bgColor2: ''},
                // {id: '6', colorStyle: '#bfdce4', colorStyle2: 'rgb(191,220,228)', bgColor: '#bfdce4', bgColor2: ''}
            ],
            //尺寸
            sizeItem: {id: '1', title: '一寸',mmSize:'25x36mm',pxSize: '295*413px', pxWidth: 295, pxHeight: 413},
            //背景色
            bgColor: '#FFFFFF',
            bgColor2: '',
            //正装
            clothId: '0',
            clothStyle: ['男装', '女装'],
            //男装女装
            clothActive: 0,
            //男装款式
            manClothList: [
                {id:'0', imgData:'../images/none-cloth.png'},
                {id:'man_1', imgData:'../images/man/1.png'},
                {id:'man_2', imgData:'../images/man/2.png'},
                {id:'man_3', imgData:'../images/man/3.png'},
                {id:'man_4', imgData:'../images/man/4.png'},
                {id:'man_5', imgData:'../images/man/5.png'},
                {id:'man_6', imgData:'../images/man/6.png'},
                {id:'man_7', imgData:'../images/man/7.png'},
                {id:'man_8', imgData:'../images/man/8.png'},
                {id:'man_9', imgData:'../images/man/9.png'},
                {id:'man_10', imgData:'../images/man/10.png'},
            ],
            //女装款式
            womanClothList: [
                {id:'0', imgData:'../images/none-cloth.png'},
                {id:'woman_1', imgData:'../images/woman/1.png'},
                {id:'woman_2', imgData:'../images/woman/2.png'},
                {id:'woman_3', imgData:'../images/woman/3.png'},
                {id:'woman_4', imgData:'../images/woman/4.png'},
                {id:'woman_5', imgData:'../images/woman/5.png'},
                {id:'woman_6', imgData:'../images/woman/6.png'},
                {id:'woman_7', imgData:'../images/woman/7.png'},
                {id:'woman_8', imgData:'../images/woman/8.png'},
                {id:'woman_9', imgData:'../images/woman/9.png'},
                {id:'woman_10', imgData:'../images/woman/10.png'},
            ],
            attachmentId: '',
            resImg: "",
            uploadImg: "../images/head.png",
            sizeTitle: "一寸",
            resData: {},
            abortCtrl: null,
            isResData: false,
            currentModelType: 'BAIDU', //getLargeModelType(),
            isUploadImg: false
        }
    },
    watch: {

    },
    created() {
        const _this = this
        let jsApiList = []
        $.getScript("../../../js/jweixin-sgccigw-1.0.0.js" /*"js/jweixin-1.0.0.js"*/, function () {
            'use strict';
            wx.ready(function () {
                wx.onHistoryBack(() => {
                    _this.home()
                    return false
                })
            });
            jsApiList = [
                'startRecordVoiceBuffer',
                'ext_AudioRecorder_Start',
                'ext_AudioRecorder_Stop',
                'onRecordBufferReceived',
                'multiWindows_subscribe',
                
                "chooseImage",
                "getLocalImgData",

                'ext_OnlineFaceRecognition_init',
                "ext_OnlineFaceRecognition_faceDetect",

                'stopRecord',
                'onHistoryBack',
            ];
            wx.config({
                beta: true, // 调用wx.invoke形式的接口值时，该值必须为true。
                debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                appId: corpid,
                timestamp: '1626832073',
                nonceStr: nonceStr,
                signature: signature,
                jsApiList: jsApiList
            });
        });
    },
    mounted() {
        this.compatibleInput()
        
        //加载背景色
        // this.loadBgColorList();
        //加载尺寸
        // this.loadSizeList();
        //加载男女装
        // this.loadClothList();
        // this.uploadIdPhotoData(3995)
        // this.attachmentId = 3995
    },
    methods: {
        //加载背景色
        loadBgColorList(){
            this.bgColorList = [{id: '1', colorStyle: '#FFFFFF'},
                {id: '2', colorStyle: '#518fda'},
                {id: '3', colorStyle: '#ea3325'},
                {id: '4', colorStyle: '#74b6f3'},
                {id: '5', colorStyle: '#eebfb5'},
                {id: '6', colorStyle: '#bfdce4'},
            ]
        },
        //加载尺寸
        loadSizeList(){
            this.sizeList = [{id: '1', title: '一寸',mmSize:'25*35mm',pxSize: '295*413px'},
                {id: '2', title: '二寸',mmSize:'25*35mm',pxSize: '295*413px'},
                {id: '3', title: '三寸',mmSize:'25*35mm',pxSize: '295*413px'},
                {id: '4', title: '四寸',mmSize:'25*35mm',pxSize: '295*413px'},
                {id: '5', title: '五寸',mmSize:'25*35mm',pxSize: '295*413px'}
            ]
        },
        uploadIdPhotoData(id) {
            let that = this
            const userId = sessionStorage.getItem("userId");
            let param = {
                "attachmentId": id,
                "timestamp": new Date().getTime() + "",
            };
            let AuthenticationSession = sessionStorage.getItem("Authentication");
            data = JSON.stringify(param)
            let sign = sm3(data);
            $.ajax({
                url: localUrlLink + iscp_port + "/tjAiAssistant/transition/uploadImgData",
                type: "post",
                async: false, //是否同步，false表示同步请求
                dataType: "json",
                data: data,
                headers: {
                    "Content-Type": "application/json;charset=UTF-8",
                    Authentication: AuthenticationSession,
                    sign: sign
                },
                success: (res, txt, xhr) => {
                    $(".curtain").css("display", "none");
                    if (res.code == 200) {
                        let data = res.resultValue

                        let uploadImg = ''
                        // if(data.img) {
                            uploadImg = data.img
                            let localData = uploadImg
                                .replace("data:image/jpg;base64,", "");
    
                            // this.attachmentId = id
                            // this.uploadImg = uploadImg
                            // this.resImg = "";
                            // this.isUploadImg = true;

                            wx.invoke("ext_OnlineFaceRecognition_init",{ data:{} },
                                (res1) => {
                                    console.log(JSON.stringify(res1)) 
                                    console.log(res1.code) 
                                    if(res1.code === 0 || res1.code === "0") {
                                        //成功处理
                                        console.log("初始化成功")

                                        wx.invoke("ext_OnlineFaceRecognition_faceDetect",{ 
                                            data:{file: localData}},
                                            (res) => {
                                                $(".curtain").css("display", "none");
                                                console.log(JSON.stringify(res))
                                                if(res.err_msg === 'ext_OnlineFaceRecognition_faceDetect:ok') {
                                                //成功处理
                                                    console.log("单张人脸")
                                                    this.attachmentId = id
                                                    this.uploadImg = uploadImg
                                                    this.resImg = "";
                                                    this.isUploadImg = true;
                                                    mui.toast("上传成功", {
                                                        duration: "long",
                                                        type: "div"
                                                    });
                                                }
                                                if(res.err_msg === 'ext_OnlineFaceRecognition_faceDetect:fail') {
                                                    //失败处理
                                                    console.log("非单张人脸")
                                                    mui.toast("请上传仅有单张人脸的图片", {
                                                        duration: "long",
                                                        type: "div"
                                                    });
                                                }
                                            })
                                    }
                                    if(res.code === -1) {
                                        //失败处理
                                        $(".curtain").css("display", "none");
                                        mui.toast("请上传仅有单张人脸的图片", {
                                            duration: "long",
                                            type: "div"
                                        });
                                        console.log(res);
                                    }
                            })
                    } else {
                        mui.toast('请稍后再试', {
                            duration: 1000,
                            type: 'div'
                        })
                    }
                },
                error: (e) => {
                    $(".curtain").css("display", "none");
                    mui.toast('请稍后再试', {
                        duration: 1000,
                        type: 'div'
                    })
                },
            });
        },
        //加载男女装
        loadClothList() {
            const userId = sessionStorage.getItem("userId");
            let param = {
                "userId": userId,
                "timestamp": new Date().getTime() + "",
            };
            let AuthenticationSession = sessionStorage.getItem("Authentication");
            data = JSON.stringify(param)
            let sign = sm3(data);
            $.ajax({
                url: localUrlLink + iscp_port + "/tjAiAssistant/imgBase64/queryList",
                type: "post",
                async: false, //是否同步，false表示同步请求
                dataType: "json",
                data: data,
                headers: {
                    "Content-Type": "application/json;charset=UTF-8",
                    Authentication: AuthenticationSession,
                    sign: sign
                },
                success: (res, txt, xhr) => {
                    if (res.code == 200) {
                        this.manClothList = res.resultValue.man;
                        this.womanClothList = res.resultValue.women;
                        //添加不需要服装
                        this.manClothList.unshift({id:'', imgData:'../images/none-cloth.png'})
                        this.womanClothList.unshift({id:'', imgData:'../images/none-cloth.png'})
                    } else {
                        mui.toast('请稍后再试', {
                            duration: 1000,
                            type: 'div'
                        })
                    }
                },
                error: (e) => {
                    $(".curtain").css("display", "none");
                    mui.toast('请稍后再试', {
                        duration: 1000,
                        type: 'div'
                    })
                },
            });
        },
        //选择尺寸
        selSize(item){
            this.sizeItem = item
            this.sizeTitle = item.title
        },
        //选择背景色
        selBgColor(item) {
            this.bgColor = item.bgColor
            this.bgColor2 = item.bgColor2
        },
        //选择正装款式（男女）
        selClothStyle(item){
            this.clothActive = item
        },
        //选择正装
        selCloth(item){
            this.clothId = item.id
        },
        hexToRgb(hex) {
            // 移除十六进制颜色代码中的'#'
            let sanitizedHex = hex.replace("#", "");
        
            // 解析红、绿、蓝值
            let r = parseInt(sanitizedHex.substring(0, 2), 16);
            let g = parseInt(sanitizedHex.substring(2, 4), 16);
            let b = parseInt(sanitizedHex.substring(4, 6), 16);
        
            return 'rgb(' + r + ',' + g + ',' + b + ')';
        },
        getParamText() {
            let text_json = {
                sizeTitle: this.sizeTitle,
                bgColor: this.bgColor,
                rgbColor: this.hexToRgb(this.bgColor),
                width: this.sizeItem.pxWidth,
                height: this.sizeItem.pxHeight,
                render: this.bgColor2 ? 1 : 0
            }
            return JSON.stringify(text_json)
            // if('BAIDU' == getLargeModelType()) {
                // return "帮我生成证件照,大小为" + this.sizeTitle + ",底色为" + this.hexToRgb(this.bgColor);
            // }else {
            //     //ALI
            //     let text_json = {
            //         pxWidth: this.sizeItem.pxWidth,
            //         pxHeight: this.sizeItem.pxHeight,
            //         bgColor: this.bgColor.replace('#', '').toUpperCase(),
            //         bgColor2: this.bgColor2.replace('#', '').toUpperCase()
            //     }
            //     if('0' != this.clothId) {
            //         text_json.clothesID = this.clothId
            //     }
            //     return JSON.stringify(text_json)
            // }
        },
        //版式照片生成
        genIdPhoto() {
            if(!this.attachmentId) {
                mui.toast("请上传单人人像照片", { duration: "long", type: "div" });
                return
            }
            let text = this.getParamText()
            console.log('证件照生成参数：', text)
            const userId = sessionStorage.getItem("userId");
            let param = {
                "userId": userId,
                "attachmentId": this.attachmentId,
                "text": text,
                "modelType": 'BAIDU', //getLargeModelType(),
                "timestamp": new Date().getTime() + "",
            };
            if(this.clothId && '0' != this.clothId) {
                param.clothId = this.clothId
            }
            $(".curtain").css("display", "block");
            let url = ''
            this.abortCtrl = streamChat(localUrlLink + iscp_port + "/tjAiAssistant/transition/generateIdPhoto", param,
                (res) => {
                    //成功回调
                    $(".curtain").css("display", "none");
                    console.log(res);
                    this.resImg = res.resultValue.url
                    url = res.resultValue.url
                    this.resData = res.resultValue
                    this.isResData = true
                    console.log(this.resData);
                }, (err) => {
                    //失败回调
                    $(".curtain").css("display", "none");
                    mui.toast("生成失败，请稍后重试", { duration: "long", type: "div" });
                }, e => {
                    //请求完成
                    // this.chatEnd = true
                    if(!url) {
                        mui.toast("生成失败，请稍后重试", { duration: "long", type: "div" });
                    }
                });
        },
        uploadFunc(type) {
            let _that = this
            this.channelId = "transfer_upload_" + _that.createNonceStr(8) + new Date().getTime() + "";

            wx.chooseImage({
                count: 1, // 默认9
                sizeType: ["original"], // 可以指定是原图还是压缩图，默认二者都有
                sourceType: ["album", "camera"], // 可以指定来源是相册还是相机，默认二者都有
                quality: 1, //压缩质量，范围0～1，数值越小，质量越低，压缩率越高（仅对jpg有效）
                success: (res) => {
                    $(".curtain").css("display", "block");
                    console.log('chooseImage', res)
                    var localId = res.localIds[0]; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
                    wx.invoke(
                        "getLocalResPath", {
                            localId: localId,
                        },
                        (res2) => {
                            console.log('getLocalResPath', res2)
                            this.getImage(res2.localResPath, localId, (fileInfo) => {
                                
                                // let localData = this.uploadImg.replace("data:image/jpeg;base64,", "");

                                // console.log('localData', localData)
                                // wx.invoke("ext_OnlineFaceRecognition_init",{ data:{} },
                                //     (res1) => {
                                //         console.log(JSON.stringify(res1)) 
                                //         console.log(res1.code) 
                                //         if(res1.code === 0 || res1.code === "0") {
                                //             //成功处理
                                //             console.log("初始化成功")

                                //             wx.invoke("ext_OnlineFaceRecognition_faceDetect",{ 
                                //                 data:{file: localData}},
                                //                 (res) => {
                                //                     $(".curtain").css("display", "none");
                                //                     console.log(JSON.stringify(res))
                                //                     if(res.err_msg === 'ext_OnlineFaceRecognition_faceDetect:ok') {
                                //                     //成功处理
                                //                         console.log("单张人脸")
                                //                     }
                                //                     if(res.err_msg === 'ext_OnlineFaceRecognition_faceDetect:fail') {
                                //                         //失败处理
                                //                         console.log("非单张人脸")
                                //                         mui.toast("请上传仅有单张人脸的图片", {
                                //                             duration: "long",
                                //                             type: "div"
                                //                         });
                                //                     }
                                //                 })
                                //         }
                                //         if(res.code === -1) {
                                //             //失败处理
                                //             $(".curtain").css("display", "none");
                                //             mui.toast("请上传仅有单张人脸的图片", {
                                //                 duration: "long",
                                //                 type: "div"
                                //             });
                                //             console.log(res);
                                //         }
                                // })

                                console.log('fileInfo', fileInfo)
                                this.checkList(res2.localResPath, fileInfo.fileName, this.channelId, fileInfo.length)

                            });
                        }
                    );
                },
            });

            // wx.invoke("ext_FileBrowser_StartPreView", {}, function (res) {
            //     _that.channelId = "transfer_upload_" + _that.createNonceStr(8) + new Date().getTime() + "";

            //     if (_that.isflageIOX) {
            //         const suffix = res.name.split('.').reverse()[0]
            //         if (!_that.imgSuffix.includes(suffix.toLocaleLowerCase())) {
            //             mui.toast('请上传仅有单张人脸的图片', {
            //                 duration: 'long',
            //                 type: 'div'
            //             })
            //             return
            //         }
            //         if(res.size > 10*1024*1024){
            //             mui.toast('上传文件大小请控制在10MB内', {
            //                 duration: 'long',
            //                 type: 'div'
            //             })
            //             return
            //         }
            //         if (checkFileNameForSensitiveWords(res.name)) {
            //             mui.toast('检测到敏感内容，请确认后再试。', {
            //                 duration: 'long',
            //                 type: 'div'
            //             })
            //             return false
            //         }
            //         console.log("ios上传文件")
            //         _that.checkList(res.filePath, res.name, _that.channelId, res.size)
            //     } else {
            //         let recordArr = JSON.parse(res.result)
            //         const suffix = recordArr[0].name.split('.').reverse()[0]
            //         if (!_that.imgSuffix.includes(suffix.toLocaleLowerCase())) {
            //             mui.toast('请上传仅有单张人脸的图片', {
            //                 duration: 'long',
            //                 type: 'div'
            //             })
            //             return
            //         }
            //         if (checkFileNameForSensitiveWords(recordArr[0].name)) {
            //             mui.toast('检测到敏感内容，请确认后再试。', {
            //                 duration: 'long',
            //                 type: 'div'
            //             })
            //             return false
            //         }
            //         if(recordArr[0].fileSize > 10 *1024*1024){
            //             mui.toast('上传图片大小请控制在10MB内', {
            //                 duration: 'long',
            //                 type: 'div'
            //             })
            //             return false
            //         }
            //         _that.checkList(recordArr[0].path, recordArr[0].name, _that.channelId, recordArr[0].fileSize)
            //     }
            // })
        },
        getImage(slocalResPath, localIds, callback) {
          wx.invoke(
            "ext_FileManager_Information", {
              data: {
                path: slocalResPath,
              },
            },
            (res) => {
                let fileInfo = JSON.parse(res.data);
                console.log('ext_FileManager_Information', fileInfo)
              let str = fileInfo.fileSize.split(".");
              if (str[1].indexOf("MB") !== -1) {
                if (Number(str[0]) >= 10) {
                  $(".curtain").css("display", "none");
                  mui.toast("图片大小不能超过10MB", {
                    duration: "long",
                    type: "div",
                  });
                  return;
                } else {
                //   if (this.isflageIOX) {
                    this.getImgBase(localIds, callback, fileInfo);
                //   } else {
                //     callback();
                //   }
                }
              } else {
                // if (this.isflageIOX) {
                  this.getImgBase(localIds, callback, fileInfo);
                // } else {
                //   callback();
                // }
              }
            }
          );
        },
        getImgBase(localIds, callback, fileInfo) {
          var a = false;
          // 根据id取图片的路径
          wx.getLocalImgData({
            localId: localIds,
            success: (res) => {
              var localData = res.localData;
              if (localData.indexOf("data:image") != 0) {
                //判断是否有这样的头部
                localData = "data:image/jpeg;base64," + localData;
              }
              localData = localData
                .replace(/\r|\n/g, "")
                .replace("data:image/jpg", "data:image/jpeg");

                // console.log('uploadImg', localData)
                // this.uploadImg = localData

              // 第一个替换的是换行符，第二个替换的是图片类型，因为在IOS机上测试时看到它的图片类型时jgp，
              // ios单独添加文件用来回显
            //   this.slocalResPath.forEach(el => {
            //     if (el.path == slocalResPath) el.file = localData
            //   });
              callback(fileInfo);
            },
          });
        },
        checkList(path, name, id, fileSize, hash, index, uploadImg) {
            console.log("fileSize的值为",fileSize)
            // $(".curtain").css("display", "block");
            let that = this
            that.disabledInp = true
            let iscp_port
            if (sessionStorage.getItem("iscp_port")) {
                iscp_port = sessionStorage.getItem("iscp_port");
            } else {
                iscp_port = ""
            }
            let Authentication = sessionStorage.getItem("Authentication");
            const timestamp = new Date().getTime() + ""
            let userId = sessionStorage.getItem("userId");
            let sign = sm3(timestamp + "&" + userId)
            that.fileName = name
            wx.invoke("ext_Net_FragmentUpload", {
                data: {
                    serverAddress: localUrlLink + iscp_port + `/tjAiAssistant/storage/splitUpload2?channelId=${id}`,
                    filePath: path,
                    fragmentSize: that.CHUNK_SIZE,
                    fileName: name,
                    fileHash: hash ? hash : '',
                    upLoadFragmentIndex: index ? index : '',
                    channelId: id,
                    headerData: {
                        sign: sign,
                        userId: userId,
                        type: '',
                        timestamp: timestamp,
                        Authentication: Authentication,
                    }
                },
            }, function (res) {
                if (res.err_msg.endsWith(":ok")) { //成功结果
                    //上传完成
                    // that.recording(id)
                    // $(".curtain").css("display", "none");
                    const suffix = name.split('.').reverse()[0]
                    // that.attachmentId = id;
                    that.uploadIdPhotoData(id)

                    // $(".curtain").css("display", "none");
                    // console.log("uploadImg", uploadImg)
                    // that.uploadImg = uploadImg

                } else if (res.err_msg.endsWith(":cancel")) {
                    $(".curtain").css("display", "none");
                    that.cleanData();
                    return
                } else {
                    $(".curtain").css("display", "none");
                    //上传失败
                    if (that.myindex != Number(res.upLoadFragmentIndex)) {
                        that.myindex = Number(res.upLoadFragmentIndex);
                        that.retryNum = 0;
                    }
                    setTimeout(() => {
                        if (that.retryNum > 4) {
                            // that.retryNum = 0
                            var btnArray = ["取消", "确定"];
                            var i = 0
                            mui.confirm(
                                "是否进行重试？",
                                "上传失败",
                                btnArray,
                                (e) => {
                                    if (i > 0) return
                                    i++
                                    if (e.index == 1) {
                                        that.checkList(path, name, id, fileSize, res.fileHash, res.upLoadFragmentIndex)
                                    } else {
                                        that.cleanData()
                                    }
                                }
                            );
                        } else {
                            that.retryNum++

                            that.checkList(path, name, id, fileSize, res.fileHash, res.upLoadFragmentIndex)
                        }

                    }, (that.retryNum + 1) * 1000)

                }
            })
        },
        calcFileSize(fileSize) {
            let kbf = (Math.floor((fileSize / 1024) * 100) / 100).toFixed(2);
            if (kbf > 1000) {
                //显示 MB
                return (Math.floor((fileSize / (1024 * 1024)) * 100) / 100).toFixed(2) + 'MB';
            }
            return kbf + 'KB';
        },
        cleanData() {
            this.disabledInp = false
            this.progressBar = false
        },
        //分享
        share(result) { 
            if(result.id != null) {
                shareIgw({
                    sceneNo: '108',
                    shareType: 1,
                    attchId: result.id
                })
            }else {
                mui.toast("暂无结果可分享", {
                    duration: "long",
                    type: "div"
                });
            }
        },
        syncToInner(result) {
            if (result.id != null) {
                mySyncToInner('证件照生成',"answerAttach=" + result.id,10,8)
            }else {
                mui.toast("暂无结果可同步图片", {
                    duration: "long",
                    type: "div"
                });
            }
        },
        //发送邮件
        sendMail(result) { 
            if (result.id != null) {
                mySendMail('证件照生成',"answerAttach=" + result.id,10,8)
            }else {
                mui.toast("暂无结果可发送邮件", {
                    duration: "long",
                    type: "div"
                });
            }
        },
        //复制按钮
        copy() {
            let text1 = this.clipboard.content;
            var clipboard = new Clipboard(".tag-read", {
                // 通过target指定要复印的节点
                text: function () {
                    return text1;
                },
            });
            clipboard.on("success", (e) => {
                addOperator(2, 11, "复制文本", 1, 1, "复制成功");
                mui.toast("复制成功", {
                    duration: "long",
                    type: "div"
                });
            });
            clipboard.on("error", (e) => {
                addOperator(2, 11, "复制文本", 1, 0, "复制失败");
            });
        },
        // 判断安卓还是ios
        compatibleInput() {
            //获取浏览器的userAgent,并转化为小写
            var ua = navigator.userAgent.toLowerCase();
            //判断是否是苹果手机，是则是true
            var isIos = ua.indexOf("iphone") != -1 || ua.indexOf("ipad") != -1;
            if (isIos) {
                this.isflageIOX = true;
            } else {
                this.isflageIOX = false;
            }
        },
        home() {
            $(location).attr("href", "../../Home.html");
        },
        createNonceStr(len) {
            var e = len ? len : 16;
            var t =
              "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
              a = t.length,
              n = "";
            for (i = 0; i < e; i++)
              n += t.charAt(Math.floor(Math.random() * a));
            return n;
        },
    }
})